/*-+-*****************************************************************************
 Copyright (C) 2009-2012 Oceanside Software Corporation (R)
 Dallas, Texas

 Author       : Jason T. Brower
 Purpose      : This file is part of a point-of-sale software package
                originally written for Table-Service Restaurants.
              
 Date         : July 8th of 2012
              
 History      : The application that this software file belongs to was 
                written over a 3-Year period.  The first version was written
                in C# .Net 3.5 using Windows Forms.  Being new to .Net at
                the time, I soon learned of Windows Presentation Foundation,
                liked the graphics capabilities and databinding so I
                migrated to WPF.  When the .Net 4.0 framework was released
                the application was migrated from 3.5 to 4.0. Now today,
                .Net 4.5 RC is out and I was already in process of migrating
                before I made this public.
                
Excuse Me     : Please excuse the coding style, it is not representative of
                my typical work.  During the three years I was under a very
                tight budget, constantly running out of funding and was 
                working 18 hour days hyped up on 5-Hour Energy.  The 
                design is not textbook.  It is monolythic because of
                previous issues I will not get into.  There are few comments
                in the code and the ones that are there may be incorrect.
                
What it is not: This is not the exact version that I took through PA-DSS 2.0
                nor is it the exact version running at my customer sites.
                I removed some details for security purposes including some
                encryption algorithms.  The reporting was removed because
                I was including a third party library that cannot be 
                published with this Open Source.
                
What it is    : This application has been running at high volume restaraunts
                for over a year.  It never freezes, crashes or does anything
                unexpected.  So long as it is built, installed and configured
                correctly, it is a strong system that we can all enhance.

Contact       : Please note that I can no longer work for free.  However, you
                can reach me at information@oceansidesw.com.                                                      

*********************************************************************************/

using System;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Input;
using System.Collections.Generic;
using System.Linq;

namespace Oceanside
{
    /// <summary>
    /// Interaction logic for EmployeeTimePunches.xaml
    /// </summary>
    public partial class QuickReportsViewer : UserControl
    {
        /// <summary>
        /// 
        /// </summary>
        public QuickReportsViewer()
        {
            InitializeComponent();
            bPrintByMenuGroup.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);
            bPrintByProduct.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);
            bPrintByEmployee.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);
            bPrintByRevType.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);
            bPrintByDaypart.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);
            bSalesByRevCenter.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);

            bPrintByMenuGroupWeek.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);
            bPrintByProductWeek.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);
            bPrintByEmployeeWeek.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);
            bPrintByRevTypeWeek.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);
            bPrintByDaypartWeek.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);
            bSalesByRevCenterWeek.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);

            bPrintByMenuGroupMonth.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);
            bPrintByProductMonth.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);
            bPrintByEmployeeMonth.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);
            bPrintByRevTypeMonth.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);
            bPrintByDaypartMonth.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);
            bSalesByRevCenterMonth.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);

            bPrintByMenuGroupYear.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);
            bPrintByProductYear.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);
            bPrintByEmployeeYear.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);
            bPrintByRevTypeYear.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);
            bPrintByDaypartYear.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);
            bSalesByRevCenterYear.ButtonDownDelegate += new Button_164_62.FunctionButtonDownDelegate(InterpretCommand_NOTHROW);

        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="cmd"></param>
        private void InterpretCommand_NOTHROW(int cmd)
        {
            try
            {
                App.InvokeStartStoryBoard_NOTHROW();
                System.Threading.Tasks.Task.Factory.StartNew(() =>
                {
                    try
                    {
                        switch (cmd)
                        {
                            case 0:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByMenuGroup();
                                break;
                            case 1:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByEmployee();
                                break;
                            case 2:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByRevenueType();
                                break;
                            case 3:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByRevenueCenter();
                                break;
                            case 4:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByDaypart();
                                break;
                            case 5:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByCountOrdered();
                                break;
                            case 6:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByMenuGroup(DateTime.Now.StartOfWeek(DayOfWeek.Monday), DateTime.Now);
                                break;
                            case 7:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByEmployee(DateTime.Now.StartOfWeek(DayOfWeek.Monday), DateTime.Now);
                                break;
                            case 8:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByRevenueType(DateTime.Now.StartOfWeek(DayOfWeek.Monday), DateTime.Now);
                                break;
                            case 9:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByRevenueCenter(DateTime.Now.StartOfWeek(DayOfWeek.Monday), DateTime.Now);
                                break;
                            case 10:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByDaypart(DateTime.Now.StartOfWeek(DayOfWeek.Monday), DateTime.Now);
                                break;
                            case 11:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByCountOrdered(DateTime.Now.StartOfWeek(DayOfWeek.Monday), DateTime.Now);
                                break;
                            case 12:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByMenuGroup(DateTime.Now.StartOfMonth(), DateTime.Now);
                                break;
                            case 13:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByEmployee(DateTime.Now.StartOfMonth(), DateTime.Now);
                                break;
                            case 14:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByRevenueType(DateTime.Now.StartOfMonth(), DateTime.Now);
                                break;
                            case 15:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByRevenueCenter(DateTime.Now.StartOfMonth(), DateTime.Now);
                                break;
                            case 16:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByDaypart(DateTime.Now.StartOfMonth(), DateTime.Now);
                                break;
                            case 17:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByCountOrdered(DateTime.Now.StartOfMonth(), DateTime.Now);
                                break;
                            case 18:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByMenuGroup(DateTime.Now.StartOfYear(), DateTime.Now);
                                break;
                            case 19:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByEmployee(DateTime.Now.StartOfYear(), DateTime.Now);
                                break;
                            case 20:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByRevenueType(DateTime.Now.StartOfYear(), DateTime.Now);
                                break;
                            case 21:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByRevenueCenter(DateTime.Now.StartOfYear(), DateTime.Now);
                                break;
                            case 22:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByDaypart(DateTime.Now.StartOfYear(), DateTime.Now);
                                break;
                            case 23:
                                PrintSpool.UseCurrentDay = true;
                                PrintSpool.PrintSalesByCountOrdered(DateTime.Now.StartOfYear(), DateTime.Now);
                                break;
                            default:
                                break;
                        }
                    }
                    catch (Exception e)
                    {
                        Logging.LogException(e);
                        UMD.ShowGuiMessageSTASafe_NOTHROW("An error occured while generating the report data.");
                    }
                });
            }
            catch (System.Exception exc)
            {
                Constants.ErrorDispatcher.Notify(Error.EType.E_PAGEDATATOOLS_INTERP_COMMAND, exc);
            }
        }
    }
}
